package com.zeyu.soc.log.profiler.core;

import java.util.ArrayList;
import java.util.List;

/**
 * The Class ContextNode.
 */
public class ContextNode {

	// ================================================================
	// Constants
	// ================================================================

	// ================================================================
	// Fields
	// ================================================================

	/** The method name. */
	private String methodName;

	/** The start time. */
	private long startTime;

	/** The end time. */
	private long endTime;

	/** The exec time. */
	private long execTime;

	/** The parent. */
	private ContextNode parent;

	/** The child list. */
	private List<ContextNode> childList = new ArrayList<ContextNode>();

	/** The elapse time ms to log. */
	private long elapseTimeMsToLog;

	// ================================================================
	// Constructors
	// ================================================================

	/**
	 * Instantiates a new context node.
	 */
	public ContextNode(String methodName, long startTime, long elapseTimeMsToLog) {
		this.methodName = methodName;
		this.startTime = startTime;
		this.elapseTimeMsToLog = elapseTimeMsToLog;
	}

	// ================================================================
	// Methods from/for super Interfaces or SuperClass
	// ================================================================

	// ================================================================
	// Public or Protected Methods
	// ================================================================

	// ================================================================
	// Getter & Setter
	// ================================================================

	/**
	 * Gets the method name.
	 */
	public String getMethodName() {
		return methodName;
	}

	/**
	 * Sets the method name.
	 */
	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}

	/**
	 * Gets the start time.
	 */
	public long getStartTime() {
		return startTime;
	}

	/**
	 * Sets the start time.
	 */
	public void setStartTime(long startTime) {
		this.startTime = startTime;
	}

	/**
	 * Gets the end time.
	 */
	public long getEndTime() {
		return endTime;
	}

	/**
	 * Sets the end time.
	 */
	public void setEndTime(long endTime) {
		this.endTime = endTime;
		this.execTime = endTime - startTime;
	}

	/**
	 * Gets the child list.
	 */
	public List<ContextNode> getChildList() {
		return childList;
	}

	/**
	 * Sets the child list.
	 */
	public void setChildList(List<ContextNode> childList) {
		this.childList = childList;
	}

	/**
	 * Gets the parent.
	 */
	public ContextNode getParent() {
		return parent;
	}

	/**
	 * Sets the parent.
	 */
	public void setParent(ContextNode parent) {
		this.parent = parent;
	}

	/**
	 * Gets the exec time.
	 */
	public long getExecTime() {
		return execTime;
	}

	/**
	 * Gets the elapse time ms to log.
	 */
	public long getElapseTimeMsToLog() {
		return elapseTimeMsToLog;
	}

	/**
	 * Sets the elapse time ms to log.
	 */
	public void setElapseTimeMsToLog(long elapseTimeMsToLog) {
		this.elapseTimeMsToLog = elapseTimeMsToLog;
	}

	// ================================================================
	// Private Methods
	// ================================================================

	// ================================================================
	// Inner or Anonymous Class
	// ================================================================

	// ================================================================
	// Test Methods
	// ================================================================
}
